/**
 * Created by charsen on 16/5/25.
 */
directives.directive('pageClassify', ["$rootScope", "tools", "$timeout", "$location", function ($rootScope, tools, $timeout, $location) {
    return {
        restrict: 'AE',
        scope: {},
        replace: true,
        link: function (scope, element, attr) {
            $rootScope.$on('PAGE_CLASSIFY_MANAGER_EV', function (e, config) {
                $(element).modal('show');
            });

            // 用户级别的信息保存
            var userConfig = tools.getUserConfig();

            scope.newClassifition = "";
            scope.newClassifyShown = true;
            scope.addNewClassify = function () {
                if (!userConfig.pageClassifies) {
                    userConfig.pageClassifies = {};
                }

                userConfig.pageClassifies[scope.newClassifition] = [];
                $rootScope.$broadcast('NEW_CLASSIFY_ADDED_EV');
                tools.updateUserConfig();
            }
        },
        templateUrl: "/trend-new-BI/app/components/pages/pageClassify/pageClassifyView.html"
    }
}]);